<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<title>朋友圈</title>
		<script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="${pageContext.request.contextPath}/js/CircleOfFriend.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/common.css"/>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/CircleOfFriend.css"/>
		<script type="text/javascript">
			$(function (){
				var filename = "${showPhoto}";
				if(filename!=""){
					var img='<img src="${pageContext.request.contextPath}/images/${showPhoto}" height="360" width="360">';
					$("#showPhoto").prepend(img);
					$("#showPhoto").css("display","block");
				}
				var page = 1;
				selectSaySomething(page);
				
				$(document).scroll(function (){
					var top = $(this).scrollTop();
					var height = $(this).height();
					var win = $(window).height()
			        if(top >= height-win){ 
			        	page++;
			        	selectSaySomething(page);
			        }  
				});
			});
			
			/**
			 * 发说说
			 */
			function sendMessage(photo,msg){
				$.ajax({
					type:"post",
					data:{photo:photo,msg:msg,uid:"${userBean.id}"},
					url:"${pageContext.request.contextPath}/cofa/sm.action",
					async:true,
					success:function (data){
						resultToClear();
						selectSaySomething(1,true);
						<% request.removeAttribute("showPhoto"); %>
					}	
				});
			}
			/**
			 * 查询说说
			 */
			function selectSaySomething(page,clear){
				$.ajax({
					type:"post",
					data:{uid:"${userBean.id}",page:page},
					url:"${pageContext.request.contextPath}/cofa/sss.action",
					success:function (data){
						createSaySomethingDiv(data,clear);
					}	
				});
			}
			/**
			 * 点赞
			 */
			function giveGoodAjax(id){
				$.ajax({
					type:"post",
					data:{uid:"${userBean.id}",id:id},
					url:"${pageContext.request.contextPath}/cofa/gga.action"
				});
			}
			
			/**
			 * 取消点赞
			 */
			function removeGoodAjax(id){
				$.ajax({
					type:"post",
					data:{uid:"${userBean.id}",id:id},
					url:"${pageContext.request.contextPath}/cofa/rga.action"
				});
			}
			/**
			 * 发送评论
			 */
			function sendCommentAjax(value,id,a){
				$.ajax({
					type:"post",
					data:{uid:"${userBean.id}",id:id,msg:value},
					url:"${pageContext.request.contextPath}/cofa/sca.action",
					success:function(data){
						var li = "<li style='width:672px;word-wrap:break-word'>"
							+ "<span style='font-size:12px'>${userBean.username} </span>"
							+"<span style='color:#999;font-size:8px'>"+data+": </span>"
							+"<span style='font-size:12px'>"+value+"</span>"
							+ "</li>";
						$(a).parent().next().find("ul").prepend(li);
						$(a).prev().val("");
					}
				});
			}
		</script>
	</head>
	<body>
	
		<div id="bodyDiv">
			<div id="userInfoDiv">
				<img id="headImgDiv" src="${pageContext.request.contextPath}/images/defaultImg.png"></img>
				<div id="usernameDiv">3048442663@qq.com</div>
				<div id="weather">
					<iframe name="weather_inc" src="http://i.tianqi.com/index.php?c=code&id=52&icon=1&num=3" 
						width="165" height="25" frameborder="0" marginwidth="0" marginheight="0" scrolling="no">
					</iframe>
				</div>
			</div>
			<div id="MessageDiv">
				<div id="sendMessage">
					<form id="sendImgForm" action="${pageContext.request.contextPath}/cofa/uli.action?id=${userBean.id}" method="post" enctype="multipart/form-data">
						<input type="file" name="imgPhoto" id="imgPhoto" />
					</form>
					<form id="sendMessageForm"  method="post">
						<textarea placeholder="说点什么吧"></textarea>
						<div id="clickSendImg"></div>
					</form>
					<button>发表</button>
					<div id="showPhoto"></div>
				</div>
				<div id="friendMessage"> 
					<%-- <div class="message">
						<img src="${pageContext.request.contextPath}/images/defaultImg.png" class="friendHeadImg"></img>
						<div class="friendName">地豆</div>
						<div class="friendTime">2018年4月23日 19:30</div>
						<div class="friendMsg">
							hahaha
							hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha
							hahahahahahahahahahahahahahahahahahahahaha
							hahahahahahahahahahahahahahaha
						</div>
						<div class="friendPhoto"></div>
						<div class="friendGood"><div class="Good"></div></div>
						<div class="friendComment">
							<textarea placeholder="评论"></textarea>	
							<button>发表</button>
						</div>
						<div class="commentArea">
							<ul>
								<li>li</li>
							</ul>
						</div>
					</div> --%>
				</div>
			</div>	
		</div>
	</body>
</html>